enum OsnConversationType:Int {
    case Single = 0
    case Group
    case Service
    case Notify
    
    init(rawValue: Int) {
        switch rawValue {
        case 0: self = .Single
        case 1: self = .Group
        case 2: self = .Service
        case 3: self = .Notify
        default: self = .Single
        }
    }
}
class DMCCConversation {
    var id:Int64 = 0
    var type = OsnConversationType.Single
    var targetId = ""
    var lastMessage = 0
    var newestMessage = ""
    var draft = ""
    var unread = 0
    var unreadMention = 0
    var unreadMentionAll = 0
    var isTop = false
    var isSilent = false
    var timestamp:Int64 = 0

    
    func getConversationType(for target: String) -> Int {
        if target.hasPrefix("OSNG") {
            return OsnConversationType.Group.rawValue
        } else if target.hasPrefix("OSNU") {
            return OsnConversationType.Single.rawValue
        } else if target.hasPrefix("OSNS") {
            return OsnConversationType.Service.rawValue
        }
        return -1
    }
    
//    func setLastMessage(_ message: DMCCMessage) {
//            self.lastMessage = message
//    }
    
    func setDraft(_ draft: String?) {
            guard let draft = draft else { return }
            self.draft = draft
    }
    
    func cleanUnread() {
            self.unread = 0
            self.unreadMention = 0
            self.unreadMentionAll = 0
        }
}
